#ifndef IMAGESCALER_H
#define IMAGESCALER_H
#include "mediaplayer.h"
#include "ffplay_def.h"
#include <libswscale/swscale.h>

typedef struct VideoFrame
{
    uint8_t *data[8] = {NULL};         // 类似FFmpeg的buf, 如果是
    int32_t linesize[8] = {0};
    int32_t width;
    int32_t height;
    int format = AV_PIX_FMT_YUV420P;
}VideoFrame;

class ImageScaler
{
public:
    ImageScaler(void);
    ~ImageScaler(void);
    RET_CODE Init(uint32_t src_width, uint32_t src_height, int src_pix_fmt,
                  uint32_t dst_width, uint32_t dst_height, int dst_pix_fmt,
                  int en_alogrithm  = SWS_FAST_BILINEAR);

    void DeInit( );
    RET_CODE Scale(const AVFrame *src_frame, AVFrame *dst_frame);
    RET_CODE Scale2(const VideoFrame *src_frame, VideoFrame *dst_frame);
    RET_CODE Scale3(const Frame *src_frame, VideoFrame *dst_frame);
private:

    SwsContext*	sws_ctx_;		//SWS对象
    AVPixelFormat src_pix_fmt_;			//源像素格式
    AVPixelFormat dst_pix_fmt_;			//目标像素格式
    int en_alogrithm_;		//Resize算法

    int src_width_, src_height_;			//源图像宽高

    int dst_width_, dst_height_;			//目标图像宽高

};

#endif // IMAGESCALER_H
